import express from 'express';
const router = express.Router();

import UserController from '@src/controller/UserController'
import validateGlobal from '@src/middleware/validate';
import Joi from 'joi';
import Paths from '@src/common/Paths';
import { validateCode } from '@src/middleware/validateCode';

router.get(Paths.Users.Get, UserController.getUsers);

router.put(Paths.Users.Update, validateGlobal(
    Joi.object({
        username: Joi.string().required(),
        email: Joi.string().email().required(),
        avatar: Joi.string().required(),
        signature: Joi.string().max(50).required(),
    })
), UserController.updateUser);

router.put(Paths.Users.UpdatePwd, validateGlobal(
    Joi.object({
        email: Joi.string().email().required(),
        password: Joi.string().required(),
        code: Joi.number().required(),
        type: Joi.string().required(),
    })
), validateCode, UserController.updatePassword);

export default router;
